from pyecharts import options as opts
from pyecharts.charts import Graph

# 知识节点列表
nodes = [
    {"name": "共同富裕目标下的中国税制改革", "symbolSize": 50},
    # 第一章
    {"name": "宏观收入分配格局", "symbolSize": 40},
    {"name": "初次分配格局", "symbolSize": 35},
    {"name": "纵向分析", "symbolSize": 30},
    {"name": "横向对比", "symbolSize": 30},
    {"name": "再分配格局", "symbolSize": 35},
    # 第二章
    {"name": "居民收入分配差距", "symbolSize": 40},
    {"name": "基尼系数变化", "symbolSize": 30},
    {"name": "再分配调节力度不足", "symbolSize": 30},
    # 第三章
    {"name": "税制问题分析", "symbolSize": 40},
    {"name": "个人所得税问题", "symbolSize": 35},
    {"name": "企业所得税问题", "symbolSize": 35},
    {"name": "社保养老问题", "symbolSize": 35},
    # 第四章
    {"name": "改革建议", "symbolSize": 40},
    {"name": "所得税改革", "symbolSize": 30},
    {"name": "房地产税调整", "symbolSize": 30},
    {"name": "消费税优化", "symbolSize": 30},
    {"name": "养老保险改革", "symbolSize": 30},
    # 国际经验
    {"name": "日本经验", "symbolSize": 35},
    # 数据节点
    {"name": "住户部门占比变化", "symbolSize": 25},
    {"name": "企业部门占比变化", "symbolSize": 25},
    {"name": "政府占比变化", "symbolSize": 25},
    {"name": "国际比较数据", "symbolSize": 25},
]

# 关系边列表
links = [
    # 总体结构
    {"source": "共同富裕目标下的中国税制改革", "target": "宏观收入分配格局"},
    {"source": "共同富裕目标下的中国税制改革", "target": "居民收入分配差距"},
    {"source": "共同富裕目标下的中国税制改革", "target": "税制问题分析"},
    {"source": "共同富裕目标下的中国税制改革", "target": "改革建议"},
    {"source": "共同富裕目标下的中国税制改革", "target": "日本经验"},
    
    # 第一章关系
    {"source": "宏观收入分配格局", "target": "初次分配格局"},
    {"source": "宏观收入分配格局", "target": "再分配格局"},
    {"source": "初次分配格局", "target": "纵向分析"},
    {"source": "初次分配格局", "target": "横向对比"},
    {"source": "纵向分析", "target": "住户部门占比变化"},
    {"source": "纵向分析", "target": "企业部门占比变化"},
    {"source": "纵向分析", "target": "政府占比变化"},
    {"source": "横向对比", "target": "国际比较数据"},
    
    # 第二章关系
    {"source": "居民收入分配差距", "target": "基尼系数变化"},
    {"source": "居民收入分配差距", "target": "再分配调节力度不足"},
    
    # 第三章关系
    {"source": "税制问题分析", "target": "个人所得税问题"},
    {"source": "税制问题分析", "target": "企业所得税问题"},
    {"source": "税制问题分析", "target": "社保养老问题"},
    
    # 第四章关系
    {"source": "改革建议", "target": "所得税改革"},
    {"source": "改革建议", "target": "房地产税调整"},
    {"source": "改革建议", "target": "消费税优化"},
    {"source": "改革建议", "target": "养老保险改革"},
    
    # 国际经验关联
    {"source": "日本经验", "target": "养老保险改革"},
]

# 生成知识图谱
graph = (
    Graph(init_opts=opts.InitOpts(width="1000px", height="600px"))
    .add(
        series_name="",
        nodes=nodes,
        links=links,
        layout="force",
        repulsion=500,
        linestyle_opts=opts.LineStyleOpts(curve=0.2),
        label_opts=opts.LabelOpts(is_show=True),
        edge_length=100,
    )
    .set_global_opts(
        title_opts=opts.TitleOpts(title="共同富裕目标下的中国税制改革知识图谱")
    )
)

graph.render("清华课题.html")